﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>btable</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/css/btable.css" />
    <script src="/static/js/inout/jquery-1.8.2.min.js"></script>
    <style>
        .tup{
            max-width: 62px;
            max-height: 62px;
        }
        .ticke{
            width: 100%;
            position: relative;
        }
        .ticke b{
            color: red;
        }
        .ticke span{
            color: red;
        }
    </style>
</head>
<body style=" background-color: gainsboro;">

<div class="ly-box" style="margin:0px; background-color: white; margin:0 10px;float: left">
    <blockquote class="layui-elem-quote" style="float: left">
        <script>
            $(function () {
                var quotewid=$(window).width()-50;
                $(".layui-elem-quote").width(quotewid);
                $(window).resize(function () {
                    var quotewid=$(window).width()-50;
                    $(".layui-elem-quote").width(quotewid);
                })
            })
        </script>
        <button type="button" class="layui-btn layui-btn-small" onclick="addopend();"><i class="fa fa-plus" aria-hidden="true"></i> 添加</button>
        <form class="layui-form" style="float:right;" action="/admin/problem/selecty" method="post">
            <div class="layui-form-item" style="margin:0;">
                <div class="layui-input-inline" style="margin-right:10px;">
                    <select name="warning">
                        <option value="">严重性</option>
                        <option value="99">所有</option>
                        <option value="1">正常</option>
                        <option value="2">一般</option>
                        <option value="3">严重</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="margin-right:10px;">
                    <select name="state">
                        <option value="">问题状态</option>
                        <option value="100">所有</option>
                        <option value="99">等待处理</option>
                        <option value="1">技术已处理</option>
                        <option value="2">测试通过</option>
                        <option value="3">版本更新</option>
                        <option value="4">处理完成</option>
                        <option value="5">忽略</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="margin-right: 0;">
                    <input type="text" name="start" id="start" placeholder="选择日期" autocomplete="off" class="layui-input" value="" onclick="layui.laydate({elem: this})">
                </div>
                <label class="layui-form-label" style="text-align: center;width: inherit;">至</label>
                <div class="layui-input-inline">
                    <input type="text" name="end" id="end" placeholder="选择日期" autocomplete="off" class="layui-input" value="" onclick="layui.laydate({elem: this})">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="title" placeholder="输入标题" value="" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux" style="padding:0;">
                    <button lay-filter="search" class="layui-btn" lay-submit><i class="fa fa-search" aria-hidden="true"></i> 查询</button>
                </div>
            </div>
        </form>
    </blockquote>
    <div id="content" style="width: 100%;height: 533px; float: left"></div>
</div>

<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/js/',
        v: new Date().getTime()
    }).use(['btable', 'form','paging','laydate'], function () {
        var btable = layui.btable(),
                $ = layui.jquery,
                laydate = layui.laydate;
                layerTips = parent.layer === undefined ? layui.layer : parent.layer, //获取父窗口的layer对象
                layer = layui.layer,//获取当前窗口的layer对象;
                form = layui.form();
        btable.set({
            openWait: true,//开启等待框
            elem: '#content',
            url: '/admin/problem/selecty', //数据源地址
            pageSize: 15,//页大小
            params: {
                t: new Date().getTime() //额外的请求参数
            },
            columns: [{ //配置数据列
                fieldName: '标题', //显示名称
                field: 'title', //字段名
                sortable: true //是否显示排序
            },{
                fieldName: '处理人',
                field: 'username',
                sortable: true
            },{
                fieldName: '创建时间',
                field: 'addTime',
                sortable: true
            },{
                fieldName: '更新时间',
                field: 'updateTime',
                sortable: true
            },{
                fieldName: '处理时间',
                field: 'groupd',
                sortable: true
            },{
                fieldName: '处理进度',
                field: 'Processing',
                sortable: true
            },{
                fieldName: '问题类型',
                field: 'titlename',
                sortable: true
            },{
                fieldName: '重要性',
                field: 'warin',
                sortable: true
            },{
                fieldName: '启用/禁用',
                field: 'status',
                format: function (id, obj){
                    //id
                    //行数据对象
                    //返回值：格式化的纯文本或html文本
                    return obj.sign;
                }
            },{
                fieldName: '问题状态',
                field: 'stutsa',
                sortable: true
            },{
                fieldName: '操作',
                field: 'id',
                format: function (val,obj) {
                    var position = "{$position}";
                    var special = "{$special}";
                    var dl = "确认处理";
                    var back = "";
                    if(obj.uid==0 && special==2){
                        position = 1;
                    }
                    if(obj.classid==2 && special==2){
                        position = 1;
                    }
                    if(obj.classid==2 && position==4 && obj.state==2){
                        position = 3
                    }
                    var disea = "";
                    if(obj.state>position-1){
                        disea = "disabled='disabled'";
                        dl = "已确认";
                        back = "style='background: aquamarine;'";
                    }else if(obj.state<position-1){
                        disea = "disabled='false'";
                        dl = "等待确认";
                        back = "style='background: aquamarine;'";
                    }
                    if(obj.classid==2 && position==4 && obj.state==3){
                        disea = "disabled='disabled'";
                        dl = "已确认";
                        back = "style='background: aquamarine;'";
                    }
                        var html = '{if condition="($position neq 5) and ($userid neq 1)"}<button type="button" '+disea+' '+back+' data-id="'+val+'" data-bd="'+obj.state+'" data-type="'+obj.classid+'" class="layui-btn layui-btn-normal layui-btn-mini ble polty" onclick="deats(this);">'+dl+'</button>{/if}' +
                                '<button type="button" class="layui-btn layui-btn-normal layui-btn-mini" data-id="'+val+'" onclick="testion(this);">留言详情</button>' +
                                '<input type="button" class="layui-btn layui-btn-normal layui-btn-mini" data-enable="'+obj.enable+'" data-stulit="'+obj.stulit+'" data-show="'+obj.show+'" data-state="'+obj.state+'" data-name="'+obj.title+'" data-id="'+val+'" data-action="liston" value="更多操作"/>';
                    return html;
                }
            }],
            even: true,//隔行变色
            field: 'id', //主键ID
            //skin: 'row',
            checkbox: false,//是否显示多选框
            paged: true, //是否显示分页
            singleSelect: false, //只允许选择一行，checkbox为true生效
            onSuccess: function ($elem) { //$elem当前窗口的jq对象
                $elem.parent().parent().find(".ticke").remove();
                $elem.parent().after('<div class="ticke"><b>流程说明</b>：<span>发现bug,发布问题流程 1：技术人员处理BUG，然后点击确认等待测试。2：测试BUG是否处理完成，然后点击确认等待主管更新。3：主管确认更新BUG，等待客服确认问题解决。4：客服确认问题是否解决点击完成。以上流程为bug解决流程。请按照以上标准实行。</span></div>');
                $elem.parent().css("margin-bottom","10px");
                $elem.children('tr').each(function () {
                    $(this).children('td:last-child').children('input').each(function () {
                        var $that = $(this);
                        var action = $that.data('action');
                        var id = $that.data('id');
                        $that.on('click', function () {
                            switch (action) {
                                case 'del': //删除
                                    layer.confirm('确定要删除？', {
                                        btn: ['确定','取消'] //按钮
                                    }, function(){
                                        var id = $that.attr('data-id');
                                        $.ajax({
                                            type:"post",
                                            dataType: "json",
                                            url: "/admin/problem/del",
                                            data:{
                                                id:id
                                            },
                                            success:function(res){
                                                if(res.status==0){
                                                    layer.msg(res.msg,{icon: 1});
                                                    setTimeout('location.href="/admin/problem/index"',1000);
                                                }else{
                                                    layer.msg(res.msg,{icon: 1});
                                                }
                                            }
                                        });
                                    }, function(){

                                    });
                                    break;
                                case 'liston':
                                    var id = $that.attr('data-id');
                                    var title = $that.attr('data-name');
                                    var enable = $that.attr('data-enable');
                                    var state = $that.attr('data-state');
                                    var show = $that.attr('data-show');
                                    var stulit = $that.attr('data-stulit');
                                    var types = $that.attr('data-type');
                                    var positions = "{$position}";
                                    var special = "{$special}";
                                    var uid = "{$userid}";
                                    var dx = "一键确认";
                                    var backs = "";
                                    if(uid==0 && special==2){
                                        position = 1;
                                    }
                                    if(types==2 && special==2){
                                        position = 1;
                                    }
                                    if(types==2 && position==4 && state==2){
                                        position = 3
                                    }
                                    var po = '';
                                    var sh = "";
                                    var str ='';
                                    if(enable==1){
                                        po="禁用";
                                    }else{
                                        po="启用";
                                    }
                                    if(show==1){
                                        sh="隐藏";
                                    }else{
                                        sh="显示";
                                    }
                                    if(stulit!=5){
                                        str = '<button type="button" data-id="'+id+'" data-opt="'+state+'" class="layui-btn layui-btn-normal layui-btn-mini czi" onclick="restl(this);">重置</button>';
                                    }
                                    var dise = "";
                                    if(state>positions-1){
                                        dise = "disabled='disabled'";
                                        dx = "已确认";
                                        backs = "style='background: aquamarine;'";
                                    }else if(state<positions-1){
                                        dise = "disabled='false'";
                                        dx = "等待确认";
                                        backs = "style='background: aquamarine;'";
                                    }
                                    if(types==2 && positions==4 && state==3){
                                        dise = "disabled='disabled'";
                                        dx = "已确认";
                                        backs = "style='background: aquamarine;'";
                                    }
                                    layer.tips('{if condition="$position neq 5"}<input type="button" value="修改" id="edit" data-action="edit" data-id="'+id+'" data-name="'+title+'" class="layui-btn layui-btn-mini" onclick="edits(this)" />{/if}' +
                                            '<button data-id="'+id+'" data-bd="'+enable+'" class="layui-btn layui-btn-normal layui-btn-mini ble" onclick="defa(this)">'+po+'</button>' +
                                            '{if condition="$position eq 0"}<input type="button" value="删除" data-id="'+id+'" class="layui-btn layui-btn-mini layui-btn-danger del" onclick="del(this)" />{/if}' +
                                            '{if condition="($position eq 0) OR ($position eq 4)"}'+str+'{/if}' +
                                            '<button type="button" class="layui-btn layui-btn-mini" data-name="'+show+'" data-id="'+id+'" onclick="showdata(this)">'+sh+'</button>' +
                                            '{if condition="($position eq 0) OR ($position eq 2) OR ($position eq 4) OR ($position eq 3)"}<input type="button" data-id="'+id+'" class="layui-btn layui-btn-normal layui-btn-mini ble" onclick="hule(this)" value="忽略"/>{/if}' +
                                            '{if condition="($position neq 5) and ($userid neq 1)"}<button type="button" '+dise+' '+backs+' data-bd="'+state+'" class="layui-btn layui-btn-normal layui-btn-mini ble polty" onclick="deatr(this);">'+dx+'</button>{/if}',$(this), {
                                        tips: [1, '#FFFFFF'],
                                        time: 4000
                                    });
                                    break;
                            }
                        });
                    });
                });
            }
        });
        btable.render();
        //监听搜索表单的提交事件
        form.on('submit(search)', function (data) {
            btable.get(data.field);
            return false;
        });
        $(window).on('resize', function (e) {
            var $that = $(this);
            $('#content').height($that.height() - 92);
        }).resize();
    });
     function addopend(){
         window.location.href="/admin/problem/addproble";
     }
    function edits(_this){
        var id = $(_this).attr("data-id");
        window.location.href="/admin/problem/edit?id="+id;
     }

    function defa(_this) {
        var m = $(_this).attr("data-bd")==1?'您是否要禁用该问题?':'您是否要启用该问题?';
        layer.confirm(m,{
            btn: ['确定','取消'] //按钮
        }, function(){
            var id = $(_this).attr("data-id");
            $.ajax({
                type:"post",
                dataType: "json",
                url: "/admin/problem/jinyong",
                data:{
                    id:id
                },
                success:function(res){
                    if(res.status==0){
                        layer.msg(res.msg);
                        setTimeout('location.href="/admin/problem/index"',1000);
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        }, function(){
        });
    }
    function del(_this) {
        layer.confirm('确定要删除？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            var id = $(_this).attr("data-id");
            $.ajax({
                type:"post",
                dataType: "json",
                url: "/admin/problem/del",
                data:{
                    id:id
                },
                success:function(res){
                    if(res.status==0){
                        layer.msg(res.msg,{icon: 1});
                        setTimeout('location.href="/admin/problem/index"',1000);
                    }else{
                        layer.msg(res.msg,{icon: 1});
                    }
                }
            });
        }, function(){

        });
    }
    function deats(_this) {
        layer.confirm("您是否确认问题?",{
            btn: ['确定','取消'] //按钮
        }, function(){
            var id = $(_this).attr("data-id");
            var bd = $(_this).attr("data-type");
            $.ajax({
                type:"post",
                dataType: "json",
                url: "/admin/problem/confirm",
                data:{
                    id:id,
                    bd:bd
                },
                success:function(res){
                    if(res.status==0){
                        layer.msg(res.msg);
                        setTimeout('location.href="/admin/problem/index"',1000);
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        }, function(){
        });
    }

    function deatr(_this) {
        layer.confirm("您是否一键确认问题?",{
            btn: ['确定','取消'] //按钮
        }, function(){
            var state = $(_this).attr("data-bd");
            $.ajax({
                type:"post",
                dataType: "json",
                url: "/admin/problem/deatr",
                data:{
                    state:state
                },
                success:function(res){
                    if(res.status==0){
                        layer.msg(res.msg);
                        setTimeout('location.href="/admin/problem/index"',1000);
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        }, function(){
        });
    }

    function restl(_this) {
        layer.confirm("您是否重置问题?",{
            btn: ['确定','取消'] //按钮
        }, function(){
            var proid = $(_this).attr("data-id");
            $.ajax({
                type:"post",
                dataType: "json",
                url: "/admin/problem/restl",
                data:{
                    proid:proid
                },
                success:function(res){
                    if(res.status==0){
                        layer.msg(res.msg);
                        setTimeout('location.href="/admin/problem/index"',1000);
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        }, function(){
        });
    }
    function hule(_this) {
        layer.confirm("您是否要忽略该问题?",{
            btn: ['确定','取消'] //按钮
        }, function(){
            var proid = $(_this).attr("data-id");
            $.ajax({
                type:"post",
                dataType: "json",
                url: "/admin/problem/hule",
                data:{
                    proid:proid
                },
                success:function(res){
                    if(res.status==0){
                        layer.msg(res.msg);
                        setTimeout('location.href="/admin/problem/index"',1000);
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        }, function(){
        });
    }
    function showdata(_this) {
        var s = $(_this).attr("data-name")==1?'您是否要隐藏该问题?':'您是否要显示该问题?';
        layer.confirm(s,{
            btn: ['确定','取消'] //按钮
        }, function(){
            var pid = $(_this).attr("data-id");
            var show = $(_this).attr("data-name");
            $.ajax({
                type:"post",
                dataType: "json",
                url: "/admin/problem/showdata",
                data:{
                    pid:pid,
                    show:show
                },
                success:function(res){
                    if(res.status==0){
                        layer.msg(res.msg);
                        setTimeout('location.href="/admin/problem/index"',1000);
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        }, function(){
        });
    }

       function testion(_this){
           var id = $(_this).attr("data-id");
           window.location.href="/admin/problem/auxiliar?id="+id;
       }
    function grouttime(_this){
        layui.use(['layer','form'], function () {
            var cons = '<form class="layui-form" id="ops"><div class="layui-form-item" style="margin-top: 20px;"><div class="layui-input-block" style="margin-left: 5px;">' +
                    '<input type="number" name="days" min="0" class="layui-input" placeholder="设置天数"  value="" style="text-align: center;"></div></div></form>';
            var ids = $(_this).attr("data-id");
            layer.open({
                type: 1,
                title: '修改用户',
                content: cons,
                btn: ['确定', '取消'],
                area: ['350px', '180px'],
                yes: function (index, layero) {
                    //这是核心的代码。
                    var days = $("[name='days']").val();
                    if(days==''){
                        layer.msg("请设置天数");
                        return false;
                    }
                    $.ajax({
                        type:"post",
                        dataType: "json",
                        url: "/admin/problem/groudtime",
                        data:{
                            days:days,
                             id:ids
                        },
                        success:function(res){
                            if(res.status==0){
                                layer.msg(res.msg);
                                setTimeout('location.href="/admin/problem/index"',1000);
                            }else{
                                layer.msg(res.msg);
                            }
                        }
                    });

                },
                maxmin: true
            });
        });
    }
</script>
</body>

</html>